def isPowerOfThree(n: int) -> bool:
   
    # 乘法思想
    # i = 1
    # while i < n:
    #     i *= 3
    # if n == i:
    #     return True
    # else:
    #     return False
    
    # 整除思想
    if n<1:
        return False
    while (n%3 == 0):
        n /= 3
        if n == 1:
            return True
        else:
            return False
            